import axios from '../utils'

const api = {
    sysUser: '/sys/getUserById',  //系统管理员 更加ID查询

    user: '/sys/saveUser', //获得当前在线用户
    getUs: '/user', //获得当前在线用户
    modifyById: '/sys/modifyById', //系统用户修改
    getUserByCompany: '/sys/getUserByCompany',
    getAllDataByPage: '/sys/getAllDataByPage', //查询同公司下用户集合
    setUserLocale: '/user/modifyLanguage',

    userRechargeAPI: '/sys/recharge', //用户充值
    getBalanceAPI: '/user/getBalance', //获取用户余额

    getRechargeAPI: '/user/getRecharge', //分页查询用户资金

    getBillingAPI: '/user/getBilling', //获取财务充值界面
    changeBillingAPI: '/company/changeBilling', //修改充值界面

    getDepositActivity: '/company/getDepositActivity', //获取存款发票
    changeDepositActivity: '/company/changeDepositActivity', //修改存款发票

    getTransactionsActivity: '/company/getTransactionsActivity', //获取交易发票
    changeTransactionsActivity: '/company/changeTransactionsActivity', //修改交易发票

    getInvoiceAPI: '/user/getInvoice', //传入类型以及id进行发票打印
    updateUserPwdAPI: '/user/modifyPass' //修改密码

}

export default api

export function getUserByCompany(parameter) {
    return axios({
        url: api.getUserByCompany,
        method: 'get',
        params: parameter
    })
}

export function getAllDataByPage(parameter) {
    return axios({
        url: api.getAllDataByPage,
        method: 'get',
        params: parameter
    })
}

export function addUser(parameter) {
    return axios({
        url: api.user,
        method: 'post',
        data: parameter
    })
}

export function modifyById(parameter) {
    return axios({
        url: api.modifyById,
        method: 'post',
        data: parameter
    })
}

/***
 * 普通用户修改
 * @param parmas
 */
export function userUpdate(parmas) {
    return axios({
        url: api.getUs,
        method: 'put',
        data: parmas
    })
}

export function getSysUser(parameter) {
    return axios({
        url: api.sysUser + parameter,
        method: 'get'
    })
}

export function getUser() {
    return axios.get(api.getUs)
}

/*
* setUserLocale 修改当前在线用户的语言
*
* */
export function setUserLocale(language) {
    return axios.get(api.setUserLocale, {
        params: {
            language
        }
    })
}

export function userRecharge(addCapitalAccountVo) {
    return axios.post(api.userRechargeAPI, addCapitalAccountVo)
}

//获取用户余额
export function getBalance(params = {}) {
    return axios.get(api.getBalanceAPI, {
        params
    })
}

export function getRecharge(params) {
    return axios.get(api.getRechargeAPI, {
        params
    })
}

//获取用户定义充值页面
export function getBilling() {
    return axios.get(api.getBillingAPI)
}
export function changeBilling(billing) {
    return axios.put(api.changeBillingAPI, {
        billing
    })
}

//存款发票
export function getDepositActivity() {
    return axios.get(api.getDepositActivity)
}
export function changeDepositActivity(depositActivity) {
    return axios.put(api.changeDepositActivity, {
        depositActivity
    })

}

//交易发票
export function getTransactionsActivity() {
    return axios.get(api.getTransactionsActivity)
}
export function changeTransactionsActivity(transactionsActivity) {
    return axios.put(api.changeTransactionsActivity, {
        transactionsActivity
    })
}

export function getInvoice(params) {
    return axios({
        url: api.getInvoiceAPI,
        method: 'get',
        params: params,
        responseType: 'blob'
    })
}

export function updateUserPwd(pass) {
    return axios.put(api.updateUserPwdAPI, {
        pass: pass,
    })
}
